Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add VertexAI provider #11

Merged
merged 18 commits into from
Sep 28, 2024
Merged

Conversation

calvingiles
Copy link
Contributor

Type of change (place an x in the [ ] that applies)

  • New sample
  • New feature
  • Bug fix
  • Documentation

Summary

Adding VertexAI as a provider (using gcloud credentials).

I have tested this works with a development slack app.

Requirements (place an x in each [ ] that applies)

  • I’ve checked my submission against the Samples Checklist to ensure it complies with all standards
  • I have ensured the changes I am contributing align with existing patterns and have tested and linted my code
  • I've read and agree to the Code of Conduct

Copy link

Thanks for the contribution! Unfortunately we can't verify the commit author(s): Calvin Giles <c***@t***.c***.nz>. One possible solution is to add that email to your GitHub account. Alternatively you can change your commits to another email and force push the change. After getting your commits associated with your GitHub account, sign the Salesforce Inc. Contributor License Agreement and this Pull Request will be revalidated.

Copy link

Thanks for the contribution! Before we can merge this, we need @calvingiles to sign the Salesforce Inc. Contributor License Agreement.

Copy link
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@calvingiles thanks a ton for this contribution! It's super neat to see the diff of a new provider! 🤖 ✨

This is all looking solid to me though I did leave a comment around environment variables and documentation that'd make setup a bit easier 🙏 Otherwise, thanks for tidying up a few places elsewhere!

I'll want to check with the team that we're equipped to maintain additional providers (and do a bit more testing myself) but I think this is off to a great start. Thanks again for sending it in and signing the CLA 🚀

README.md Outdated Show resolved Hide resolved
ai/providers/vertexai.py Outdated Show resolved Hide resolved
@zimeg zimeg added the enhancement New feature or request label Sep 25, 2024
@calvingiles
Copy link
Contributor Author

I have made the changes according to your comments and done a general pass of the README for OpenAI and Anthropic comments to mention Vertex too to avoid confusion.

@calvingiles
Copy link
Contributor Author

I am happy to make any other changes to fit in with the project.

Copy link
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is super great! Thanks so much for those updates 🙏

I gave the models a run and am always impressed with the speed of response, but I did find one error with a model that we might want to address. I left a few thoughts, but feel free to suggest what you find best!

The README was also reading well and I took a second pass at it with some of the confusions I was finding during setup 📚 I also left a few nits in comments that might not be so important, so feel free to ignore these.

After things are looking good to you, I think we're in a good place to merge this! The Gemini models are widely used and battle-tested, and I'm hoping others will find it neat to find here. Exciting!! 🚀

ai/providers/vertexai.py Outdated Show resolved Hide resolved
ai/providers/vertexai.py Outdated Show resolved Hide resolved
ai/providers/vertexai.py Outdated Show resolved Hide resolved
ai/providers/vertexai.py Outdated Show resolved Hide resolved
@calvingiles
Copy link
Contributor Author

Thanks! The comments all seem reasonable so will make the required fixes.

@calvingiles
Copy link
Contributor Author

All changes complete - I think we are ready to merge?

Copy link
Member

@zimeg zimeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking solid to me! Really appreciate the updates 🏆

I made a few more changes that were mostly formatting related (sorting imports and similar) but also updated the system_instruction setup slightly. I'm a fan of adding details to the models, but now set the client settings as unique variables before creating the client.

I left a few notes on this and am interested in how this might continue to change with updating models, but for now I think we're set to ship 🚢 💨

All of the models work will with this setup and it's neat to switch between all of the selections 👀

"name": "Gemini 1.0 Pro 001",
"provider": VERTEX_AI_PROVIDER,
"max_tokens": 8192,
"system_instruction_supported": False,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a super nice approach and I'm glad it can be known within the models of this class 🙏

Comment on lines +92 to +96
system_instruction = None
if self.MODELS[self.current_model]["system_instruction_supported"]:
system_instruction = system_content
else:
prompt = system_content + "\n" + prompt
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this to remove **kwargs since it wasn't so clear which arguments were being updated before generation and I was finding this error with pyright:

Argument of type "str" cannot be assigned to parameter "tool_config" of type "ToolConfig | None" in function "__init__"
Type "str" is not assignable to type "ToolConfig | None"
"str" is not assignable to "ToolConfig"
"str" is not assignable to "None"

I found that these changes continue to work fine for both cases, and I'm hoping the set variables before model setup helps make future updates clear 🔭

@zimeg zimeg merged commit 565db77 into slack-samples:main Sep 28, 2024
3 checks passed
@calvingiles calvingiles deleted the add-vertex-provider branch September 28, 2024 06:40
@calvingiles
Copy link
Contributor Author

Thanks! Those changes all make sense.

As an aside, I was reading the docs again and noticed that they replicate some of the instructions here - you might want to add some of the additions from the readme there too? Not sure where they get populated from though.

@zimeg
Copy link
Member

zimeg commented Sep 28, 2024

@calvingiles Great call! That page is saved in the slackapi/bolt-python repo as part of the docs here 🔍

We definitely want to make similar updates to that page to keep things fresh, and we should also make a few notes on this in a MAINTAINERS_GUIDE.md for this project 👀

All of your changes already have been great, so don't feel obligated to tackle this too! I'll plan to take a pass at these updates in the next few days 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:signed enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants